home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 22 / 4 / DISK2247.ZIP / CBASE101.ZIP / CBASE.ZIP / CBGETKCU.C < prev    next >
Text File  |  1990-06-21  |  2KB  |  96 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbgetkcu.c    1.4 - 90/06/20" */
  5.  
  6. /* ansi headers */
  7. #include <errno.h>
  8. /*#include <string.h>*/
  9.  
  10. /* library headers */
  11. #include <blkio.h>
  12. #include <btree.h>
  13.  
  14. /* local headers */
  15. #include "cbase_.h"
  16.  
  17. /*man---------------------------------------------------------------------------
  18. NAME
  19.      cbgetkcur - get cbase key cursor
  20.  
  21. SYNOPSIS
  22.      #include <cbase.h>
  23.  
  24.      int cbgetkcur(cbp, field, cbkposp)
  25.      cbase_t *cbp;
  26.      int field;
  27.      cbkpos_t *cbkposp;
  28.  
  29. DESCRIPTION
  30.      The cbgetkcur function gets the position of the key cursor of the
  31.      specified field in cbase cbp.  The cursor position is returned in
  32.      the location pointed to by cbkposp.
  33.  
  34.      cbgetkcur will fail if one or more of the following is true:
  35.  
  36.      [EINVAL]       cbp is not a valid cbase pointer.
  37.      [EINVAL]       field is not a valid field number for cbase cbp.
  38.      [EINVAL]       cbkposp is the NULL pointer.
  39.      [CBELOCK]      cbp is not locked.
  40.      [CBENOPEN]     cbp is not open.
  41.  
  42. SEE ALSO
  43.      cbgetrcur, cbsetkcur.
  44.  
  45. DIAGNOSTICS
  46.      Upon successful completion, a value of 0 is returned.  Otherwise,
  47.      a value of -1 is returned, and errno set to indicate the error.
  48.  
  49. ------------------------------------------------------------------------------*/
  50. int cbgetkcur(cbp, field, cbkposp)
  51. cbase_t *cbp;
  52. int field;
  53. cbkpos_t *cbkposp;
  54. {
  55.     btpos_t btpos;
  56.  
  57.     /* initialize automatic aggregates */
  58.     memset(&btpos, 0, sizeof(btpos));
  59.  
  60.     /* validate arguments */
  61.     if (!cb_valid(cbp) || cbkposp == NULL) {
  62.         errno = EINVAL;
  63.         return -1;
  64.     }
  65.  
  66.     /* check if not open */
  67.     if (!(cbp->flags & CBOPEN)) {
  68.         errno = CBENOPEN;
  69.         return -1;
  70.     }
  71.  
  72.     /* validate arguments */
  73.     if (field < 0 || field >= cbp->fldc) {
  74.         errno = EINVAL;
  75.         return -1;
  76.     }
  77.  
  78.     /* check if not locked */
  79.     if (!(cbp->flags & CBLOCKS)) {
  80.         errno = CBELOCK;
  81.         return -1;
  82.     }
  83.  
  84.     /* get key cursor position */
  85.     if (btgetcur(cbp->btpv[field], &btpos) == -1) {
  86.         CBEPRINT;
  87.         return -1;
  88.     }
  89.  
  90.     /* load return argument */
  91.     memcpy(cbkposp, &btpos, sizeof(cbkpos_t));
  92.  
  93.     errno = 0;
  94.     return 0;
  95. }
  96.